# -*- coding:utf-8 -*-
import datetime

import config.MongoConnection as mongo;

'''
ts_code 代码
start_date 开始日期
end_date 结束日期
days 多少天的数据，默认0表示所有
'''
def daily(ts_code, start_date="", end_date = None, days=0):
  if end_date is None:
    end_date = datetime.datetime.now().strftime('%Y%m%d');

  return list(mongo.getDB().daily.find({
    "ts_code": ts_code,
    "trade_date":{"$gte": start_date, "$lte": end_date}
  }).limit(days));